home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / fly8111-.000 / fly8111- / fly8 / MSDOS / settimer.c < prev    next >
C/C++ Source or Header  |  1979-12-31  |  716b  |  54 lines

  1. /* --------------------------------- settimer.c ----------------------------- */
  2.  
  3. /* This is part of the flight simulator 'fly8'.
  4.  * Author: Eyal Lebedinsky (eyal@ise.canberra.edu.au).
  5. */
  6.  
  7. /* Sets the PC timer 0 to mode 3.
  8. */
  9.  
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <conio.h>
  13.  
  14. #include "pc8254.h"
  15.  
  16. static short near
  17. disable (void)
  18. {
  19.     short    flags;
  20.  
  21.     _asm {
  22.         pushf
  23.         pop    flags
  24.         cli
  25.     }
  26.     return (flags);
  27. }
  28.  
  29. static void near
  30. enable (short flags)
  31. {
  32.     _asm {
  33.         push    flags
  34.         popf
  35.     }
  36. }
  37.  
  38. int
  39. main ()
  40. {
  41.     short    flags;
  42.  
  43.     flags = disable ();
  44.     outp (COMMAND_REG, WRITE_CH0);    /* write timer 0 */
  45.     outp (CHANNEL_0, 0);
  46.     outp (CHANNEL_0, 0);
  47.     enable (flags);
  48.  
  49.     printf ("Timer 0 set to mode 3\n");
  50.  
  51.     exit (0);
  52.     return (0);
  53. }
  54.